const express = require('express');
const router = express.Router();

router.get('/', (req, res) => { 
    const content = [];
    for(let i = 0; i < 100; i++)
        content.push({
            id: `2019${i}`,
            dealerCode: `dealerCode${i}`,
            dealerName: `总代名称${i}`,
            lcCode: `lcCode00${i}`,
            versionCode: `${i}`,
            issueCountry: '中国',
            issueBank: '中国银行',
            issuePrice: '550',
            issueDate: '2020-03-02T07:49:31.607Z',
            currency: 1,
            lcKind: 1,
            effectiveDate: '2020-03-02T07:49:31.607Z',
            expirationDate: '2020-03-02T07:49:31.607Z',
            creatorName: 'creatorName',
            createTime: '2020-03-02T07:49:31.607Z',
            lcStatus: 1,
            rowVersion: 'rowVersion',
            options: [
                'update',
                'close',
                'submit',
                'approve',
                'receive',
                'financeApprove'
            ]
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 100,
        }
    });
});
router.get('/forSaleConfirmation', (req, res) => {
    const content = [];
    for(let i = 0; i < 50; i++)
        content.push({
            id: `2019${i}`,
            dealerCode: `dealerCode${i}`,
            dealerName: `总代名称${i}`,
            lcCode: `lcCode00${i}`,
            versionCode: `${i}`,
            issueCountry: '中国',
            issueBank: '中国银行',
            issuePrice: '550',
            issueDate: '2020-03-02T07:49:31.607Z',
            currency: 1,
            lcKind: 1,
            effectiveDate: '2020-03-02T07:49:31.607Z',
            expirationDate: '2020-03-02T07:49:31.607Z',
            creatorName: 'creatorName',
            createTime: '2020-03-02T07:49:31.607Z',
            lcStatus: 1,
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 100,
        }
    });
});
router.get('/:id', async(req, res, next) => {
    res.json({
        message: '',
        payload: {
            id: '001',
            lcCode: 'lcCode001',
            dealerCode: 'dealerCode001',
            dealerName: 'dealerName001',
            branchCode: 'branchCode001',
            branchName: 'branchName001',
            brandCode: 'brandCode',
            brandName: 'brandName',
            versionCode: 'versionCode',
            lcApplicant: 'lcApplicant',
            issueCountry: 'issueCountry',
            issueBank: 'issueBank',
            lcPayMentDays: 'lcPayMentDays',
            issuePrice: 'issuePrice',
            issueDate: '2020-03-02T08:40:53.602Z',
            lastLoadDate: '2020-03-02T08:40:53.602Z',
            effectiveDate: '2020-03-02T08:40:53.602Z',
            expirationDate: '2020-03-02T08:40:53.602Z',
            isAllowBatch: true,
            isAllowTransfer: false,
            lcKind: 1,
            lcStatus: 1,
            currency: 1,
            quantity: '100',
            creatorName: 'creatorName',
            createTime: '2020-03-02T08:40:53.602Z',
            modifierName: 'modifierName',
            modifyTime: '2020-03-02T08:40:53.602Z',
            abandonerName: 'abandonerName',
            abandonTime: '2020-03-02T08:40:53.602Z',
            remark: 'remark',
            rowVersion: 'string',
            options: ['update', 'close', 'approve', 'submit', 'receive', 'financeApprove'],
            details: [
                {
                    id: '001',
                    invoiceCode: 'invoiceCode',
                    cashInPrice: 3213,
                    cashInDate: '2020-03-03T09:27:25.754Z',
                    cancelBillNumber: 'das2135421',
                    isCancel: true,
                    cancelDate: '2020-03-03T09:27:25.754Z',
                    registerName: 'registerName',
                    registerTime: '2020-03-03T09:27:25.754Z',
                    remark: 'remark',
                }
            ],
            usedDetails: [
                {
                    id: '001',
                    saleOrderCode: 'saleOrderCode',
                    transBatchCode: 'transBatchCode',
                    transBatchPrice: 21331,
                    saleConfirmationCode: 'saleConfirmationCode',
                    orderPrice: 1120.00,
                    orderDate: '2020-03-03T09:30:33.129Z',
                    payMentDate: '2020-03-03T09:30:33.129Z',
                    userName: 'userName',
                    userTime: '2020-03-03T09:30:33.129Z',
                }
            ]
        }
    });
});

router.post('/', async(req, res, next) => {
    res.json({
        message: '新增成功'
    });
});

router.put('/:id', async(req, res, next) => {
    res.json({
        message: '编辑成功'
    });
});

router.put('/:id/receive', (req, res) => {
    res.json(
        {
            message: '到款登记成功'
        }
    );
});

router.put('/:id/close', (req, res) => {
    res.json(
        {
            message: '关闭成功'
        }
    );
});

router.put('/:id/financeApprovePass', (req, res) => {
    res.json(
        {
            message: '审核通过'
        }
    );
});

router.put('/:id/financeApproveReject', (req, res) => {
    res.json(
        {
            message: '审核不通过'
        }
    );
});

router.put('/:id/approve', (req, res) => {
    res.json(
        {
            message: '审核成功'
        }
    );
});

router.put('/:id/submit', (req, res) => {
    res.json(
        {
            message: '提交成功'
        }
    );
});

router.get('/export', async(req, res, next) => {
    res.json({
        message: '导出成功',
        payload: 'Mock导出'
    });
});

router.post('/import', (req, res) => {
    res.json({
        message: 'success',
        payload: '导入成功'
    });
});

module.exports = router;
